rule("vs2005")
    on_load(function (target) 
        target:set("toolchains", "msvc", {vs="2005"})
        -- print("2005")
    end)
rule_end()

rule("vs2022")
    on_load(function (target) 
        target:set("toolchains", "msvc", {vs="2022"})
        -- print("2022")
    end)
rule_end()

rule("BaseInc")
    on_load(function (target)
        target:add("includedirs","$(projectdir)/Base/Include")
        target:add("includedirs","$(projectdir)/Base/Include/Interface")
    end)
rule_end()

rule("BaseLink")
    on_load(function (target)
        target:add("links", "Base")

        local arc = ""
        if target:is_arch("x86") then 
            arc = "x86"
        elseif target:is_arch("x64") then 
            arc = "x64"
        end

        local mode = ""
        if is_mode("release") then 
            mode = "release"
        elseif is_mode("debug") then 
            mode = "debug"
        end

        local BaseLinkDir = path.join("$(projectdir)","$(buildir)", "$(os)", arc, mode)        

        target:add("linkdirs", BaseLinkDir)
    end)
rule_end()


rule("PrintVar")
    on_load(function (target) 
        print("$(projectdir)")
        print("$(curdir)")
        print("$(buildir)")
        print("$(os)")
        print("$(host)")

        print("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;8.0)" .. " : this1")
        print("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;8.0)\\VC7\\bin" .. " : this2")
        print("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;8.0)\\VC" .. " : this3")
        print("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;8.0)\\VC\\Auxiliary\\Build" .. " : this4")
        print("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;8.0)\\VC\\Auxiliary\\Build" .. " : this5")

        local arc = ""
        if target:is_arch("x86") then 
            arc = "x86"
        elseif target:is_arch("x64") then 
            arc = "x64"
        end

        local mode = ""
        if is_mode("release") then 
            mode = "release"
        elseif is_mode("debug") then 
            mode = "debug"
        end

        local BaseLinkDir = path.join("$(projectdir)","$(buildir)", "$(os)", arc, mode)

        print(BaseLinkDir)

        -- import("detect.sdks.find_vstudio")
        -- print(find_vstudio({vcvars_ver = 8.0}))
        -- local vs = find_vstudio({vcvars_ver = 8.0})
        -- for k,_ in pairs(vs) do 
        --     print(k)
        -- end
        -- print(vs)
    end)
rule_end()


add_rules("mode.release", "mode.debug")

includes("Base", "test")
